package com.example.demo.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

@Controller
@RequestMapping("/hello")
public class HelloController {
    @RequestMapping("h1")
    @PostMapping
    @GetMapping
    public String hello(Model model, @RequestParam String gender){//"hello"为方法名，可任意修改
        model.addAttribute("name","Sanda");
        return "redirect:hello";//返回的字符串为“hello”模板视图文件的文件名
    }

    @RequestMapping("h2")
    public String hello2(){
        return "hello";
    }
}


